//添加子节点
export const addBtnChildrenTool = (fn) => {
    return {
        name: "button",
        args: {
            markup: [{
                    tagName: "circle",
                    selector: "button",
                    attrs: {
                        r: 8,
                        stroke: "#2f89d6",
                        "stroke-width": 2,
                        fill: "white",
                        cursor: "pointer",
                        refX: "100%",
                        refY: "50%",
                    },
                },
                {
                    tagName: "text",
                    textContent: "+",
                    selector: "icon",
                    attrs: {
                        fill: "#2f89d6",
                        "font-size": 20,
                        "font-weight": "bold",
                        "text-align": "center",
                        "line-height": 20,
                        "text-anchor": "middle",
                        "pointer-events": "none",
                        y: "0.3em",
                    },
                },
            ],

            x: "99%",
            y: "50%",
            width: 16,
            height: 16,
            offset: {
                x: 8,
                y: 0
            },
            onClick({
                cell
            }) {
                fn(cell, "down")
            },
        },
    }
}

//添加父节点
export const addBtnParentTool = (fn) => {
    return {
        name: "button",
        args: {
            markup: [{
                    tagName: "circle",
                    selector: "button",
                    attrs: {
                        r: 8,
                        stroke: "#2f89d6",
                        "stroke-width": 2,
                        fill: "white",
                        cursor: "pointer",
                        refX: "100%",
                        refY: "50%",
                    },
                },
                {
                    tagName: "text",
                    textContent: "+",
                    selector: "icon",
                    attrs: {
                        fill: "#2f89d6",
                        "font-weight": "bold",
                        "font-size": 20,
                        "line-height": 20,
                        "text-align": "center",
                        "text-anchor": "middle",
                        "pointer-events": "none",
                        y: "0.3em",
                    },
                },
            ],

            x: "0",
            y: "50%",
            width: 16,
            height: 16,
            offset: {
                x: -5,
                y: 0
            },
            onClick({
                cell
            }) {
                fn(cell, "up")
            },
        },
    }
}

//隐藏子节点
export const decreaseBtnChildrenTool = (fn) => {
    return {
        name: "button",
        args: {
            markup: [{
                    tagName: "circle",
                    selector: "button",
                    attrs: {
                        r: 8,
                        stroke: "#2f89d6",
                        "stroke-width": 2,
                        fill: "white",
                        cursor: "pointer",
                        refX: "100%",
                        refY: "50%",
                    },
                },
                {
                    tagName: "text",
                    textContent: "-",
                    selector: "icon",
                    attrs: {
                        fill: "#2f89d6",
                        "font-weight": "bold",
                        "font-size": 20,
                        "line-height": 20,
                        "text-align": "center",
                        "text-anchor": "middle",
                        "pointer-events": "none",
                        y: "0.3em",
                    },
                },
            ],

            x: "99%",
            y: "50%",
            width: 16,
            height: 16,
            offset: {
                x: 5,
                y: 0
            },
            onClick({
                cell
            }) {
                fn(cell, "down")
            },
        },
    }
}

//隐藏父节点
export const decreaseBtnParentTool = (fn) => {
    return {
        name: "button",
        args: {
            markup: [{
                    tagName: "circle",
                    selector: "button",
                    attrs: {
                        r: 8,
                        stroke: "#2f89d6",
                        "stroke-width": 2,
                        fill: "white",
                        cursor: "pointer",
                        refX: "100%",
                        refY: "50%",
                    },
                },
                {
                    tagName: "text",
                    textContent: "-",
                    selector: "icon",
                    attrs: {
                        fill: "#2f89d6",
                        "font-weight": "bold",
                        "font-size": 20,
                        "line-height": 20,
                        "text-align": "center",
                        "text-anchor": "middle",
                        "pointer-events": "none",
                        y: "0.3em",
                    },
                },
            ],

            x: "0",
            y: "50%",
            width: 16,
            height: 16,
            offset: {
                x: -5,
                y: 0
            },
            onClick({
                cell
            }) {
                fn(cell, "up")
            },
        },
    }
}

//隐藏子节点
export const workspaceBtnTool = (ndoe,fn) => {

    fontWidth = 150
    return {
        name: "workspaceBtn",
        args: {
            markup: [{
                    tagName: "rect",
                    selector: "button",
                    attrs: {
                        r: 8,
                        stroke: "#2f89d6",
                        "stroke-width": 2,
                        fill: "white",
                        cursor: "pointer",
                        refX: "0%",
                        refY: "0%",
                    },
                },
                {
                    tagName: "text",
                    textContent: ndoe.workspace,
                    selector: "icon",
                    attrs: {
                        fill: "#2f89d6",
                        "font-weight": "bold",
                        "font-size": 14,
                        "line-height": 14,
                        "text-align": "center",
                        "text-anchor": "middle",
                        "pointer-events": "none",
                        y: "0.3em",
                    },
                },
            ],

            x: "0%",
            y: "0%",
            width: fontWidth,
            height: 18,
            offset: {
                x: 0,
                y: -14
            },
            onClick({
                cell
            }) {
                fn(cell, "down")
            },
        },
    }
}

export var obj = {}